package components.dialogs.effects
{
	import UIFree.uif_component;
	
	import classes.c_util;
	
	import components.dialogs.c_elementPropDlg;
	import components.dialogs.c_filterPropDlg;
	import components.dialogs.c_propertyDialog;
	import components.editor.c_baseElement;
	
	import flash.events.Event;
	import flash.filters.DropShadowFilter;
	
	public class c_Shadow extends c_filterPropDlg {
		private static const MAXDISTANCE: Number = 50
		
		public function c_Shadow(parent:uif_component, a_element:c_baseElement, a_title:String='', modal:Boolean=false, canClose:int=2) {
			super(parent, a_element, a_title, modal, canClose);
		}
		
		override protected function propertyList():Array {
			return [
				{
					title	: 'Прозрачность',
					type	: c_propertyDialog.PTYPE_NUMBER,
					value	: shadowFilter.alpha * 100
				},{
					title	: 'Размытие',
					type	: c_propertyDialog.PTYPE_NUMBER,
					value	: shadowFilter.blurX
				},{
					title	: 'Цвет тени',
					type	: c_propertyDialog.PTYPE_COLORPICKER,
					value	: shadowFilter.color
				},{
					title	: 'Направление',
					type	: c_propertyDialog.PTYPE_DIRECT,
					value	: {
						angle		: shadowFilter.angle + 90,
						distance	: shadowFilter.distance / MAXDISTANCE
					}
				}
			]
		}
		
		override protected function filterClass():Class {
			return DropShadowFilter;
		}
		
		protected function get shadowFilter(): DropShadowFilter {
			return filter as DropShadowFilter;
		}
		
		override protected function updateElement():void {
			shadowFilter.alpha = values[0].value / 100;
			shadowFilter.blurX = values[1].value;
			shadowFilter.blurY = values[1].value;
			shadowFilter.color = values[2].value;
			shadowFilter.angle = values[3].value.angle - 90;
			shadowFilter.distance = values[3].value.distance * MAXDISTANCE;
			super.updateElement();
		}
	}
}